package com.yunxi.controller.customer;

import com.alibaba.dubbo.config.annotation.Reference;
import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.CurrentUser;
import com.yunxi.core.web.LoginInfo;
import com.yunxi.core.web.ResponseUtil;
import com.yunxi.customer.pojo.CustomerLinkVO;
import com.yunxi.customer.service.CustomerLinkDubboService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 客户联系人 前端控制器
 * </p>
 *
 * @author
 * @since 2019-05-14
 */
@RestController
@RequestMapping("/admin/customerlink")
@Api(tags = "pms:customerlink", description = "客户联系人接口")
public class CustomerLinkController {
   private static final Logger logger = LoggerFactory.getLogger(CustomerLinkController.class);

   @Autowired
   CustomerLinkDubboService customerLinkDubboService;

   @GetMapping("/page")
   @ApiOperation(value = "查询分页")
   public ApiResult page(CustomerLinkVO customerLinkVO, @RequestParam(required = true) Integer pageNum, @RequestParam(required = true) Integer pageSize) throws Exception {
      return ResponseUtil.ok(customerLinkDubboService.findPageByVO(customerLinkVO, pageNum, pageSize));
   }

   @GetMapping("/load")
   @ApiOperation(value = "读取单个")
   public ApiResult load(CustomerLinkVO customerLinkVO, @CurrentUser LoginInfo loginInfo) throws Exception {
      return ResponseUtil.ok(customerLinkDubboService.getById(customerLinkVO.getCustomerLinkId()));
   }

   @PostMapping("/save")
   @ApiOperation(value = "保存信息")
   public ApiResult save(@RequestBody CustomerLinkVO customerLinkVO, @CurrentUser LoginInfo loginInfo) throws Exception {
      customerLinkDubboService.saveOrUpdate(customerLinkVO);
      return ResponseUtil.ok("success");
   }

   @PostMapping("/del")
   @ApiOperation(value = "删除")
   public ApiResult del(@RequestBody CustomerLinkVO customerLinkVO) throws Exception {
      customerLinkDubboService.removeById(customerLinkVO.getCustomerLinkId());
      return ResponseUtil.ok("success");
   }

/*@PostMapping("/export")
@ApiOperation(value = "导出excel")
public Object export(@RequestParam Map<String,Object> params) throws Exception {
return ResponseUtil.ok(customerLinkDubboService.findMapByList(params));
}*/
}
